<?php
/**
 * Created by PhpStorm.
 * User: lee
 */

use Biz\service\trade\OrderRefund as sOrderRefund;
use Biz\tools\ImageRule;

class ApplyAction extends ActionPlugin
{
    const USER_LEVEL = self::LEVEL_REGISTER;

    public function main()
    {
        $orderNo = $this->getRequest()->getPost('order_no', '');
        $skuId = $this->getRequest()->getPost('sku_id', 0);

        $data = [];
        $data['reason'] = $this->getRequest()->getPost('reason', 0);
        $data['type_refund'] = $this->getRequest()->getPost('type_refund', 0);
        $data['receipt_status'] = $this->getRequest()->getPost('receipt_status', 0);
        $data['refund_amount'] = $this->getRequest()->getPost('refund_amount', 0);
        $data['refund_remark'] = $this->getRequest()->getPost('refund_remark', '');
        $data['images_content'] = $this->getRequest()->getPost('images_content', '');

        ImageRule::detectToJson($data['images_content']);

        $data = sOrderRefund::applyRefund($this->uid, $orderNo, $skuId, $data);

        $this->setSuccess($data);
    }
}